package util.AST.Terminal;

import checker.SemanticException;
import util.Visitor;
import util.AST.Command.Command;

/**
 * AST class
 * @version 2010-september-04
 * @discipline Compiladores
 * @author Gustavo H P Carvalho
 * @email gustavohpcarvalho@ecomp.poli.br
 */
public class Identifier extends Terminal {
	
	public static final int GLOBAL = 0;
	public static final int LOCAL = 1;
	
	private String tipo;
	private Command nodeDeclaration;

	public Identifier(String spelling) {
		super(spelling);
	}

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}

	public String getTipo() {
		return tipo;
	}
	
	public void setNodeDeclaration(Command node) {
		this.nodeDeclaration = node;
	}

	public Command getNodeDeclaration() {
		return nodeDeclaration;
	}
	
	@Override
	public String toString(int level) {
		return "Identifier(" + this.getSpelling() + ")\n";
	}
	
	public String toStringDecorada(int level) {
		return "Identifier(" + this.getSpelling()+ ") (" + this.getTipo()+") ("+ this.getNodeDeclaration().getClass().getSimpleName() + ")\n";
	}

	@Override
	public Object visit(Visitor v, Object arg) throws SemanticException {
		return v.visitIdentifier(this, arg);
	}

}
